﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Commonlib;
namespace AlbonWeb.Manager.AccountManager
{
    public partial class SelectMenu : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //绑定父级菜单 
                bindMenu("0", repTopMenu);
            }
        }
        //根据pid绑定菜单 
        protected void bindMenu(string parentid,Repeater rep)
        {
            string cmdstr = "select * from Menu where active=1 and parentID="+parentid;
            SqlHelper.BindRepeater(rep, SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null);
        }

        //绑定子菜单 
        protected void repTopMenu_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            string pid = ((HiddenField)e.Item.FindControl("hfparentid")).Value;
            Repeater repMenu = (Repeater)e.Item.FindControl("repMenu");
            bindMenu(pid, repMenu);
        }
    }
}